package controllers

import play.api._
import play.api.Play.current

import libs.concurrent.Akka
import play.api.mvc._
import com.booksea.parser.JingDongParser

object Application extends Controller {
  
  def index = Action {
    Ok(views.html.index())
  }
  
  def buy(keyword:String) = Action {
    var books = JingDongParser.search(keyword)
    Ok("OK"+books.mkString)
  }

  def search = Action {
    Async {
        Akka.future { longComputation() }.map { result =>
          Ok("Got " + result)
        }
      }
    //Ok(views.html.search())
  }

  def longComputation(){
    Thread.sleep(10000);
    println("sleep for 10 seconds")
  }
  
}